<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('订单流水列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId" class="form-inline">
            <select class="form-control mr-1" id="searchType" name="searchType">
                <option value="0">按订单</option>
                <option value="1">按课程</option>
            </select>
            <input class="form-control mr-1" id="searchKey" placeholder="订单id/订单号" type="text" name="searchKey" />
            <a class="btn btn-primary btn-rounded mr-1" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
            <a class="btn btn-warning btn-rounded" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var authStatusDatas = [[${@dict.getType('qdx_order_detail_state')}]];

    $(function() {
        $("#searchType").change(function () {
            var holderStr = "订单id/订单号";
            if ($(this).val() === '1') {
                holderStr = '课程id/课程标题';
            }
            $('#searchKey').attr('placeholder', holderStr);
        });

        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: "/my/order/detail/list.json",
            modalName: "订单流水",
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'orderNo',
                    title: '订单号', formatter: function (value, row, index) {
                        return "<a href='javascript:void(0)' onclick=orderInfo('" + value + "')>" + value + "</a>";
                    }
                },
                {
                    field: 'courseName',
                    title: '商品名称'
                },
                {
                    field: 'price',
                    title: '金额',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return row.price / 100;
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'authStatus',
                    title: '课程状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(authStatusDatas, value);
                    }
                },
                {
                    field: 'payTime',
                    title: '支付时间'
                }]
        };
        $.table.init(options);
    });

    //订单详情页
    function orderInfo(orderNo) {
        layer.open({
            type: 2,
            area: ['90%', '95%'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "订单详情",
            content: "/my/order/view.html?orderNo="+orderNo
        });
    }
</script>
</body>
</html>